<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>



    <table border="1">
        <caption>商品列表</caption>
        <tr>
            <th>商品标题</th>
            <th>商品价格</th>
            <th>商品销量</th>
        </tr>
    </table>

    <script>
        let p1 = {};
        p1.name = "王冉婷";
        p1.age = 18;
        p1.run = function () {
            console.log(this.name + ":" + this.age);
        }
        p1.run();

        let p2 = {
            name: "王冉婷",
            age: 19,
            run: function () {
                console.log(this.name + ":" + this.age);
            }
        }
        p2.run();
        let arr = [
            { title: "小米手机", price: 5000, sale: 5000 },
            { title: "移动电源", price: 5000, sale: 4500 },
            { title: "华为手表", price: 5000, sale: 8000 },
            { title: "苹果14Promax", price: 13500, sale: 5000 }
        ];
        let table = document.querySelector("table");
        for (let product of arr) {
            let tr = document.createElement("tr");
            let i1 = document.createElement("td");
            let i2 = document.createElement("td");
            let i3 = document.createElement("td");
            i1.innerHTML = product.title;
            i2.innerHTML = product.price;
            i3.innerHTML = product.sale;
            tr.append(i1, i2, i3);
            table.append(tr)
        }






    </script>
</body>

</html>